package com.demo.rmi.client;

import com.demo.rmi.server.HelloInterface;
import com.demo.rmi.server.UserInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;

public class RmiClient {

    private static final Logger logger = LoggerFactory.getLogger(RmiClient.class);

    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
       /* HelloInterface helloInterface = (HelloInterface) Naming.lookup("rmi://localhost:9999/helloRmi");
        String result = helloInterface.say("zhangsan");
        logger.info("调用成功，输出：" + result);
        UserInterface userInterface = (UserInterface)Naming.lookup("rmi://localhost:9999/user");
        String result2 = userInterface.getuser();
        logger.info("调用成功，输出：" + result2);*/
        //{"address":"rmi://localhost:9633/user-app/userService","port":9633,"name":"UserService","id":"192.168.1.102:9633","status":"OK","validate":true}
        //{"address":"rmi://localhost:9633/user-app/userDetail","port":9633,"name":"UserDetailService","id":"192.168.1.102:9633","status":"OK","validate":true}
        Remote r1 = Naming.lookup("rmi://localhost:9633/user-app/userService");
       Remote r2 = Naming.lookup("rmi://localhost:9633/user-app/userDetail");
       logger.info("成功...");
    }
}
